﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;
using TiaoTaoHelper.Wtm.Units.EFCore;

#nullable disable

namespace HengTong.DataAccess.Migrations
{
    /// <inheritdoc />
    public partial class 培训考试表字段错误优化 : TransactionalMigration
    {
        /// <inheritdoc />
        protected override void UpWithTransaction(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysPersonMedical_SysPersonMedicalBatche_MedicalExamId",
                table: "SysPersonMedical");

            migrationBuilder.DropForeignKey(
                name: "FK_SysPersonTrainExam_SysPersonTrainBatche_SysPersonTrainID",
                table: "SysPersonTrainExam");

            migrationBuilder.DropIndex(
                name: "IX_SysPersonTrainExam_SysPersonTrainID",
                table: "SysPersonTrainExam");

            migrationBuilder.DropColumn(
                name: "SysPersonTrainID",
                table: "SysPersonTrainExam");

            migrationBuilder.RenameColumn(
                name: "SysTrainId",
                table: "SysPersonTrainExam",
                newName: "PersonTrainBatcheId");

            migrationBuilder.RenameColumn(
                name: "MedicalExamId",
                table: "SysPersonMedical",
                newName: "PersonMedicalBatcheId");

            migrationBuilder.RenameIndex(
                name: "IX_SysPersonMedical_MedicalExamId",
                table: "SysPersonMedical",
                newName: "IX_SysPersonMedical_PersonMedicalBatcheId");

            migrationBuilder.CreateIndex(
                name: "IX_SysPersonTrainExam_PersonTrainBatcheId",
                table: "SysPersonTrainExam",
                column: "PersonTrainBatcheId");

            migrationBuilder.AddForeignKey(
                name: "FK_SysPersonMedical_SysPersonMedicalBatche_PersonMedicalBatcheId",
                table: "SysPersonMedical",
                column: "PersonMedicalBatcheId",
                principalTable: "SysPersonMedicalBatche",
                principalColumn: "ID");

            migrationBuilder.AddForeignKey(
                name: "FK_SysPersonTrainExam_SysPersonTrainBatche_PersonTrainBatcheId",
                table: "SysPersonTrainExam",
                column: "PersonTrainBatcheId",
                principalTable: "SysPersonTrainBatche",
                principalColumn: "ID");
        }

        /// <inheritdoc />
        protected override void DownWithTransaction(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_SysPersonMedical_SysPersonMedicalBatche_PersonMedicalBatcheId",
                table: "SysPersonMedical");

            migrationBuilder.DropForeignKey(
                name: "FK_SysPersonTrainExam_SysPersonTrainBatche_PersonTrainBatcheId",
                table: "SysPersonTrainExam");

            migrationBuilder.DropIndex(
                name: "IX_SysPersonTrainExam_PersonTrainBatcheId",
                table: "SysPersonTrainExam");

            migrationBuilder.RenameColumn(
                name: "PersonTrainBatcheId",
                table: "SysPersonTrainExam",
                newName: "SysTrainId");

            migrationBuilder.RenameColumn(
                name: "PersonMedicalBatcheId",
                table: "SysPersonMedical",
                newName: "MedicalExamId");

            migrationBuilder.RenameIndex(
                name: "IX_SysPersonMedical_PersonMedicalBatcheId",
                table: "SysPersonMedical",
                newName: "IX_SysPersonMedical_MedicalExamId");

            migrationBuilder.AddColumn<Guid>(
                name: "SysPersonTrainID",
                table: "SysPersonTrainExam",
                type: "uniqueidentifier",
                nullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_SysPersonTrainExam_SysPersonTrainID",
                table: "SysPersonTrainExam",
                column: "SysPersonTrainID");

            migrationBuilder.AddForeignKey(
                name: "FK_SysPersonMedical_SysPersonMedicalBatche_MedicalExamId",
                table: "SysPersonMedical",
                column: "MedicalExamId",
                principalTable: "SysPersonMedicalBatche",
                principalColumn: "ID");

            migrationBuilder.AddForeignKey(
                name: "FK_SysPersonTrainExam_SysPersonTrainBatche_SysPersonTrainID",
                table: "SysPersonTrainExam",
                column: "SysPersonTrainID",
                principalTable: "SysPersonTrainBatche",
                principalColumn: "ID");
        }
    }
}
